package Zoo.View.LeaderView;

import Zoo.Entity.ZoomenEntity;
import Zoo.Handler.AddZoomenViewHandler;
import Zoo.View.LeaderView.LeaderView1;

import javax.swing.*;
import java.awt.*;

/**
 * 1、园长增加动物饲养员
 */


public class AddZoomenView extends JDialog {
    JPanel jPanel=new JPanel();

    JLabel idNumberLable =new JLabel("身份证号");
    JTextField idNumberTxt=new JTextField();
    JLabel phoneLable =new JLabel("联系电话");
    JTextField phoneTxt=new JTextField();
    JLabel nameLable =new JLabel("姓名");
    JTextField nameTxt=new JTextField();

    JButton addBtn =new JButton("添加");

    AddZoomenViewHandler addZoomenViewHandler;

    public AddZoomenView(LeaderView1 leaderView1){
        super(leaderView1,"添加动物饲养员信息",true);

       addZoomenViewHandler=new AddZoomenViewHandler(this,leaderView1);


        idNumberLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(idNumberLable);
        idNumberTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(idNumberTxt);

        phoneLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(phoneLable);
        phoneTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(phoneTxt);

        nameLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(nameLable);
        nameTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(nameTxt);


        Container contentPane=getContentPane();
        contentPane.add(jPanel);
        //监听
        addBtn.addActionListener(addZoomenViewHandler);
        jPanel.add(addBtn);

        setSize(350,500);
        setLocationRelativeTo(null);
        //DISPOSE_ON_CLOSE：只销毁当前的窗体
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setResizable(false);
        setVisible(true);


    }

    public ZoomenEntity buildZoomenEntity(){
        ZoomenEntity zoomenEntity=new ZoomenEntity();

        zoomenEntity.setIdNumeber(idNumberTxt.getText());
        zoomenEntity.setPhone(phoneTxt.getText());
        zoomenEntity.setZoomenName(nameTxt.getText());

        return zoomenEntity;
    }
}
